package com.hengpeng.itfinbase.persist;

import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.hengpeng.common.persist.entity.AuditedEntity;
import com.hengpeng.common.web.annotation.HtmlInput;
import com.hengpeng.common.web.annotation.HtmlInputType;
import com.hengpeng.itfinbase.CacheType;
import com.hengpeng.itfinbase.idAssign.AbstractAssign18IdEntity;


/**
 * <pre>
 * 系统组
 * </pre>
 * @author linriqing
 * @version 1.0, 2010-7-19
 */
@Entity
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE, region = CacheType.SECOND_CACHE_DEFAULT)
public class AppGroup extends AbstractAssign18IdEntity implements AuditedEntity
{
	private static final long serialVersionUID = 1375284442850617084L;

	@Column(length = 50)
	@HtmlInput(label = "描述", maxLength = 50, type = HtmlInputType.TEXTAREA, index = 3, nullable = false)
	private String description;

	@Column(length = 50)
	@HtmlInput(label = "扩展信息", maxLength = 50, type = HtmlInputType.TEXT, index = 2, nullable = true)
	private String extValue;

	@Column(length = 20)
	@HtmlInput(label = "分组名称", maxLength = 20, type = HtmlInputType.TEXT, index = 1, nullable = false)
	private String name;

	@ManyToOne(fetch = FetchType.EAGER)
	@HtmlInput(label = "父分组", type = HtmlInputType.TEXT, valueProperty = "id", labelProperty = "name")
	@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
	private AppGroup parent;

	@ManyToMany(fetch = FetchType.EAGER, mappedBy = "groups")
	private Set<AppUser> users;

	public String getDescription()
	{
		return description;
	}

	public String getExtValue()
	{
		return extValue;
	}

	public String getName()
	{
		return this.name;
	}

	public AppGroup getParent()
	{
		return parent;
	}

	public Set<AppUser> getUsers()
	{
		return users;
	}

	public void setDescription(String description)
	{
		this.description = description;
	}

	public void setExtValue(String extValue)
	{
		this.extValue = extValue;
	}

	public void setName(String name)
	{
		this.name = name;
	}

	public void setParent(AppGroup parent)
	{
		this.parent = parent;
	}

	public void setUsers(Set<AppUser> users)
	{
		this.users = users;
	}

}